import { Link } from '@brillout/docpress'
import { UiFrameworkExtension, ConfigSpec } from '../../components'

<ConfigSpec
  env="client (server can import but not call it)"
  global={null}
/>

By using `prefetch('/some/url')` you can programmatically prefetch pages.

Using `prefetch()` enables you to speed up page navigation when you can predict what the next page will (most likely) be.

For example:

```tsx
import { prefetch } from 'vike/client/router'

function Form() {
  return <form onSubmit={onSubmit}>{/* ... */}</form>
}

async function onSubmit() {
  // Fetch the next page
  prefetch('/form/success')
  // In parallel, make a request to the server
  await someRequestToServer()
  // The assets of the next page may already be fetched at
  // this point, before even calling navigate()
  await navigate('/form/success')
}
```


## Without `vike-{react,vue,solid}`

If you don't use a <UiFrameworkExtension />, then you need to use <Link text="Client Routing" href="/client-routing" /> to be able to use `prefetch()`. Prefetching doesn't work with <Link text="Server Routing" href="/server-routing" />.


## See also

- <Link href="/prefetchStaticAssets" />
- <Link href="/preloading" />
